package com.sysu.ooad.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.sysu.ooad.entity.Teacher;

public class CheckTeacherLoginInterceptor implements Interceptor {

	public void destroy() {
		
	}

	public void init() {
		
	}

	public String intercept(ActionInvocation invocation) throws Exception {
		Map<String, Object> session = invocation.getInvocationContext().getSession();
		Teacher teacher = (Teacher)session.get("teacher");
		if(teacher == null) {
			return Action.LOGIN;
		}
		else {
			return invocation.invoke();
		}
	}
	
}
